/**
 * 
 */
package com.rapwaves.feeds.content.widgets;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Frame;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.rapwaves.feeds.content.beans.VideoContent;

/**
 * @author asanthan
 * 
 */
public class VideoContentUI extends Composite {

	private static VideoContentUiBinder uiBinder = GWT.create(VideoContentUiBinder.class);

	interface VideoContentUiBinder extends UiBinder<Widget, VideoContentUI> {
	}
	
	private VideoContent bean;

	public VideoContentUI(VideoContent bean) {
		initWidget(uiBinder.createAndBindUi(this));
		photo.setUrl(bean.getThumbUrl());
		videoLink.setText(bean.getMessage());
		videoLink.setHref(bean.getLink());
		videoLink.setTarget("_blank");
		this.bean = bean;
	}

	
	@UiField
	VerticalPanel videoPanel;
	
	@UiField
	HorizontalPanel videoImgPanel;
	
	@UiField
	Image photo;
	
	@UiField
	Anchor videoLink;
	
	@UiHandler(value="photo")
	void onClick(ClickEvent e) {
		videoImgPanel.removeFromParent();
		Frame frameField = new Frame(bean.getVideoUrl());
		frameField.setHeight("300px");
		frameField.setWidth("400px");
		videoPanel.add(frameField);
		
	}
	
}
